package com.yyfax.pay.order.model.vo;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.io.xml.QNameMap;
import com.thoughtworks.xstream.io.xml.StaxDriver;
import com.thoughtworks.xstream.io.xml.StaxWriter;

import java.io.Serializable;
import java.io.StringWriter;

@XStreamAlias("REQUEST")
public class ProtocolBindVO implements Serializable {

    @XStreamAlias("VERSION")
    private String version;

    @XStreamAlias("MCHNTCD")
    private String merchantCode;

    @XStreamAlias("USERID")
    private String userId;

    @XStreamAlias("TRADEDATE")
    private String orderDate;

    @XStreamAlias("MCHNTSSN")
    private String orderId;

    @XStreamAlias("ACCOUNT")
    private String accountName;

    @XStreamAlias("CARDNO")
    private String cardNo;

    @XStreamAlias("IDTYPE")
    private String certif_tp;

    @XStreamAlias("IDCARD")
    private String idNo;

    @XStreamAlias("MOBILENO")
    private String phone;

    @XStreamAlias("MSGCODE")
    private String msgCode;

    @XStreamAlias("SIGN")
    private String sign;

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getMerchantCode() {
        return merchantCode;
    }

    public void setMerchantCode(String merchantCode) {
        this.merchantCode = merchantCode;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getOrderDate() {
        return orderDate;
    }

    public void setOrderDate(String orderDate) {
        this.orderDate = orderDate;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public String getAccountName() {
        return accountName;
    }

    public void setAccountName(String accountName) {
        this.accountName = accountName;
    }

    public String getCardNo() {
        return cardNo;
    }

    public void setCardNo(String cardNo) {
        this.cardNo = cardNo;
    }

    public String getCertif_tp() {
        return certif_tp;
    }

    public void setCertif_tp(String certif_tp) {
        this.certif_tp = certif_tp;
    }

    public String getIdNo() {
        return idNo;
    }

    public void setIdNo(String idNo) {
        this.idNo = idNo;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getMsgCode() {
        return msgCode;
    }

    public void setMsgCode(String msgCode) {
        this.msgCode = msgCode;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public String toXml() {
        QNameMap qmap = new QNameMap();
        qmap.setDefaultPrefix("");
        StaxDriver staxDriver = new StaxDriver(qmap);
        XStream xstream = new XStream(staxDriver);
        xstream.autodetectAnnotations(true);
        xstream.ignoreUnknownElements();
        xstream.alias("REQUEST", ProtocolBindVO.class);
        try {
            StringWriter strWriter = new StringWriter();
            StaxWriter sw = new StaxWriter(staxDriver.getQnameMap(), staxDriver.getOutputFactory().createXMLStreamWriter(strWriter), false, true);
            xstream.marshal(this, sw);
            sw.close();
            return "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>"+ strWriter.toString();
            //return strWriter.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
